<template>
  <div class="search-bar">
    <el-form :inline="true" :model="searchForm" class="search-form">
      <el-form-item label="年份">
        <el-input
          v-model="searchForm.vepYear"
          placeholder="请输入核算年份"
          clearable
          style="width: 150px"
        />
      </el-form-item>
      <el-form-item label="城市">
        <el-input
          v-model="searchForm.vepCity"
          placeholder="请输入城市名称"
          clearable
          style="width: 200px"
        />
      </el-form-item>
      <el-form-item label="区县">
        <el-input
          v-model="searchForm.vepDistrict"
          placeholder="请输入区县名称"
          clearable
          style="width: 200px"
        />
      </el-form-item>
      <el-form-item label="乡镇">
        <el-input
          v-model="searchForm.vepTown"
          placeholder="请输入乡镇名称"
          clearable
          style="width: 200px"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleSearch">
          <el-icon><Search /></el-icon>
          搜索
        </el-button>
        <el-button @click="handleReset">
          <el-icon><Refresh /></el-icon>
          重置
        </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup>
import { reactive } from 'vue'
import { Search, Refresh } from '@element-plus/icons-vue'

const emit = defineEmits(['search', 'reset'])

const searchForm = reactive({
  vepYear: '',
  vepCity: '',
  vepDistrict: '',
  vepTown: ''
})

const handleSearch = () => {
  emit('search', searchForm)
}

const handleReset = () => {
  Object.keys(searchForm).forEach(key => {
    searchForm[key] = ''
  })
  emit('reset')
}
</script>

<style scoped>
.search-bar {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-form {
  margin: 0;
}
</style> 